<template>
	<view class="content">



		<view class="headcontent">

			<view class="head_one">
				<text id="user_type">商户管理</text>
				<view class="user_view">

					<image class="user_image" :src="imageSrc" />
					<text class="user_text">{{ data.role_type == 1 ? '商户管理员' : '加油员' }}</text>
				</view>

			</view>

			<view class="nav_items">
				<view class="nav_item" @click="goScan()">
					<image src="../../static/index/sao_yi_sao_white.png" class="btn_img" />
					<text class="btn_text">扫一扫</text>
				</view>

				<view class="nav_item" @click="goEwm()">
					<image src="../../static/index/er_wei_ma_white.png" class="btn_img" />
					<text class="btn_text">二维码</text>
				</view>

				<view class="nav_item" @click="goFinance">
					<image src="../../static/index/iv_cai_wu.png" class="btn_img" />
					<text class="btn_text">财务</text>
				</view>

			</view>

			<view>



			</view>




		</view>




		<view class="card_view">

			<view class="card_one_line">
				<view class="ymd_view">
					<!-- <button @click="isSelected = !isSelected" :style="{backgroundColor: isSelected ? 'red' : 'initial', color: selected ? 'white' : 'initial'}">点击我</button> -->
					<view class="day" @click="clickYmd(1)" :class="['.day',isSelected==1?'active':'day']">日</view>
					<view class="month" @click="clickYmd(2)" :class="['.month',isSelected==2?'active':'month']">月</view>
					<view class="year" @click="clickYmd(3)" :class="['.year',isSelected==3?'active':'year']">年</view>
				</view>


				<view class="order_nums_view">
					<text id="order_nums_tv">订单数量：</text>
					<text id="tv_num">{{data.order_num}}</text>
				</view>

			</view>

			<view style="display: flex; flex-direction: column; align-items: center;">
				<view class="cirle_view">
					<text style="font-size: 32rpx; font-weight:bolder;">销售金额</text>
					<text style="font-size: 42rpx; font-weight:bolder;">{{data.shop_price}}元</text>
				</view>
			</view>


		</view>


		<view class="msg_card">


			<view class="card_line">

				<view class="msg_view">
					<text style="font-size: 32rpx; font-weight: bold; margin-right: 15rpx;">实时消息</text>
					<image :animation="animationData" @click="rotateImage"
						src="../../static/index/iv_shang_jia_shua_xin.png" style="width:36rpx; height: 36rpx; ">
					</image>

				</view>

				<view class="voice_prompts">
					<text>语音提示</text>
					<switch style="transform: scale(0.7);" color="#3280F5" />
				</view>



			</view>
			<scroll-view scroll-y="true" scroll-with-animation="true">

				<block v-for="(item,index) in orderList" :key="index">
					<view class="view_item">

						<text id="tv_msg_name">{{item.order_name}}</text>
						<view class="line2">
							<text id="tv_time">{{item.created_at}}</text>
							<text id="tv_money">+{{item.shop_price}}</text>
						</view>
						<view style="height: 0.5rpx; background-color: #e5e5e5; margin-bottom: 15rpx;"
							v-if="index !== orderList.length - 1"></view>
					</view>
				</block>

			</scroll-view>
		</view>





	</view>
</template>

<script>
	import ajax from '@/api/api.js';
	import url from '@/api/url.js';

	export default {
		data() {
			return {
				imageSrc: '',
				isSelected: 1,
				time_type: 1,
				data: {},
				orderList: [],
				animationData: {},
				rateDeg: 360

			}
		},
		onLoad() {
			this.getData()
			this.getList()
		},
		methods: {
			rotateImage() {

				// 	animation.rotate(360).step(); // 旋转360度
				// 	this.animationData = animation.export(); // 将动画应用到图片上
				// this.animationData = uni.createAnimation({
				// 					duration: 1500,
				// 					timingFunction:'ease',
				// 					transformOrigin: '50% 50%'
				// 				})
				// 				this.animationData.rotate(rateDeg).step()
				// 				this.animationData = this.animationData.export()

				// this.rateDeg +=360
				// if (this.animationData) {
				// 	// 如果上一次的动画实例存在，就清除它
				// 	this.animationData = null;
				// }
				this.animationData = uni.createAnimation({
					duration: 1500,
					timingFunction: 'ease',
					transformOrigin: '50% 50%'
				})
				this.animationData.rotate(360).step()
				this.animationData = this.animationData.export()

				setTimeout(() => {
					this.animationData = uni.createAnimation({
						timingFunction: "step-start",
						transformOrigin: "50%,50%",
						duration: 0
					});

					this.animationData.rotate(0).step();
					this.animationData = this.animationData.export()
				}, 1500)




				this.getList()

			},



			getData() {
				this.$londing();
				ajax(url.storeManagement, {
					data: {
						// #ifdef MP-WEIXIN
						// #endif
						is_xcx: 1,
						type: 1,
						time_type: this.time_type

					}
				}).then(res => {

					if (res.data.code == 1) {
						this.data = res.data.data
						if (this.data.role_type == 1) {
							this.imageSrc = "../../static/index/iv_jia_you_white.png"
						} else {
							this.imageSrc = "../../static/index/iv_jia_you_white.png"
						}

					} else {
						uni.showToast({
							icon: 'error',
							title: res.data.msg
						})
					}

				}).catch(err => {
					console.log(err)
				});
			},

			getList() {
				this.$londing()
				ajax(url.storeManagement, {
					data: {
						// #ifdef MP-WEIXIN
						// #endif
						is_xcx: 1,
						type: 2,
						time_type: this.time_type

					}
				}).then(res => {
					if (res.data.code != 1) {
						uni.showToast({
							icon: 'none',
							title: res.data.msg
						})
						return;
					}
					this.orderList = res.data.data
					console.log("orderList ====>>" + this.orderList)

				}).catch(err => {
					console.log(err)
				});


			},


			clickYmd(ymd) {
				console.log("ymd...........................===>" + ymd)
				this.time_type = ymd
				this.isSelected = ymd
				this.getData()
			},
			goFinance() {
				uni.navigateTo({
					url: '../finance/finance'
				})
			},
			goScan(){
				uni.scanCode({
					
					success: (res) => {
						console.log("res ====>"+res.result)
					}
				})
			},
			goEwm(){
				uni.navigateTo({
					url:'/pages/ewm/ewm'
				})
			}
		}

	
	}
</script>

<style lang="scss">
	.content {

		height: 100%;
		display: flex;
		flex-direction: column;


		.headcontent {
			display: flex;
			flex-direction: column;
			align-items: center;
			height: 282rpx;
			background-color: $app-staus-color;


			.head_one {
				display: flex;
				flex-direction: row;
				align-items: center;
				margin-top: 72rpx;

				#user_type {
					font-size: 36rpx;
					color: white;
					font-weight: bold;
					margin-right: 12rpx;
				}

				.user_view {
					height: 35rpx;
					padding: 5rpx 8rpx 5rpx 8rpx;
					border: 1px solid white;
					border-radius: 30rpx;
					display: flex;
					align-items: center;


					.user_image {

						width: 20rpx;
						height: 20rpx;
					}

					.user_text {
						font-size: 22rpx;
						color: white;
					}

				}

			}



			.nav_items {
				margin-top: 48rpx;
				width: 750rpx;
				justify-content: space-around;
				display: flex;

				.nav_item {
					align-items: center;
					display: flex;
					flex-direction: column;

					.btn_img {
						width: 56.5rpx;
						height: 57.6rpx;
					}

					.btn_text {
						font-size: 28rpx;
						color: white;
					}
				}

			}
		}

		.card_view {

			display: flex;
			flex-direction: column;
			border-radius: 30rpx;
			height: 450rpx;
			background-size: cover;
			margin-top: 10px;
			margin-left: 10px;
			margin-right: 10px;
			background-image: url('../../static/index/iv_shang_hu_xiao_shou_bg.png');

			.card_one_line {
				justify-content: space-between;

				display: flex;

				.ymd_view {
					height: 50rpx;
					border-radius: 15rpx;
					margin-top: 11rpx;
					margin-left: 20rpx;
					display: flex;


					.year {
						font-size: 28rpx;
						border-radius: 0rpx 15rpx 15rpx 0rpx;
						border-top: 1rpx solid $app-staus-color;
						border-bottom: 1rpx solid $app-staus-color;
						border-right: 1rpx solid $app-staus-color;
						text-align: center;
						width: 70rpx;

						&.active {
							color: wheat;
							background-color: $app-staus-color;
						}
					}


					.month {
						font-size: 28rpx;
						text-align: center;
						width: 70rpx;
						border-right: 1rpx solid $app-staus-color;
						border-top: 1rpx solid $app-staus-color;
						border-bottom: 1rpx solid $app-staus-color;

						&.active {
							color: wheat;
							background-color: $app-staus-color;
						}
					}

					.day {
						font-size: 28rpx;
						border-radius: 15rpx 0rpx 0rpx 15rpx;
						text-align: center;
						width: 70rpx;
						border-right: 1rpx solid $app-staus-color;
						border-left: 1rpx solid $app-staus-color;
						border-top: 1rpx solid $app-staus-color;
						border-bottom: 1rpx solid $app-staus-color;

						&.active {
							color: wheat;
							background-color: $app-staus-color;
						}
					}





				}

				.order_nums_view {
					margin-top: 32rpx;
					margin-right: 23rpx;

					#order_nums_tv {
						font-weight: bold;
						font-size: 30rpx;
					}

					#tv_num {
						font-weight: bold;
						font-size: 30rpx;
						color: $app-staus-color;
					}


				}
			}

			.cirle_view {
				justify-content: center;
				align-items: center;
				display: flex;
				flex-direction: column;
				width: 323rpx;
				height: 327rpx;
				border: 15rpx solid;
				border-color: #2E81F5;
				border-radius: 180rpx;


			}

		}

		.msg_card {
			background-color: white;
			display: flex;
			flex-direction: column;
			border-radius: 30rpx;
			min-height: 450rpx;
			background-size: cover;
			margin-top: 10px;
			margin-left: 10px;
			margin-right: 10px;

			.card_line {
				margin-top: 30rpx;
				justify-content: space-between;
				flex-direction: row;
				display: flex;


				.msg_view {
					margin-left: 20rpx;
					display: flex;
					align-items: center;
				}

			}

			.view_item {

				margin-right: 20rpx;
				margin-left: 20rpx;

				#tv_msg_name {
					font-size: 30rpx;
					color: #333;
					font-weight: bolder;
				}

				.line2 {
					display: flex;
					justify-content: space-between;

					#tv_time {
						color: #666666;
						font-size: 24rpx;
					}

					#tv_money {
						font-weight: bolder;
						font-size: 30rpx;
						color: #F64441;
					}
				}
			}

		}

	}
</style>